<!DOCTYPE html>
<html lang="en">
<head>
    <!--<meta charset="UTF-8">-->
    <title>onchange函数的演示</title>
    <script>
        function fun(){
            var str = document.getElementById("txt").value;
            console.log(str);
            document.getElementById("txt").value = str.toUpperCase();

        }
    </script>
</head>
<body>
<input id="txt" type="text"  onchange="fun()" /><br />
</body>
</html>